package 最大子矩阵;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] s = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                s[i][j] = in.nextInt();
                s[i][j] += s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1];
            }
        }
        int res = Integer.MIN_VALUE;
        for (int x1 = 1; x1 <= n; x1++) {
            for (int x2 = x1; x2 <= n; x2++) {
                for (int y1 = 1; y1 <= n; y1++) {
                    for (int y2 = y1; y2 <= n; y2++) {
                        int sum = s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1];
                        res = Math.max(sum, res);
                    }
                }
            }
        }
        System.out.println(res);
    }

}